
var app = getApp()
Page({
  data: {
    
  },
  onLoad: function (e) {
    var that = this;
    if (e && e.orderid){
      that.setData({
        orderId: e.orderid
      })
    }
    if(e&&e.type){
      that.setData({
        type: e.type
      })
    }
    if (!app.globalData.plumSession) {
      console.log("暂未获取到session");
      app.wechatSq(that);
    } else {
      that.requestSuccesstip();
      app.requestAd(that)
    }
  },
  requestSuccesstip:function(){
    var that = this;
    var orderid = that.data.orderId;
    //发起请求，获取列表列表
    wx.showLoading({
      title: '加载中',
    })
    wx.request({
      url: app.globalData.requestUrl,
      data: {
        map: 'applet_community_orderFinish_detail_v2',
        tid: orderid
      },
      success: function (res) {
        if (res.data.ec == 200) {
          console.log(res.data.data);
          that.setData({
            orderInfo: res.data.data
          })
          if (res.data.data.paytypeId==4){
            wx.setNavigationBarTitle({
              title: '下单成功',
            })
          }
        } else {
          app.errorTip(that, res.data.em, 2000);
        }
      },
      complete: function () {
        wx.hideLoading();
      }
    });
  },
  enterIndex:function(){
    app.backHome();
  },
  seeOrderDetail:function(){
    var orderId = this.data.orderId;
    var type = this.data.type;
    var redirect_type = this.data.orderInfo.redirect_type
    var url = '/subpages1/orderDetail/orderDetail?orderid=' + this.data.orderInfo.orderId
    if (redirect_type == 'list'){
      url = '/subpages/myorder/myorder?type=hadpay'
    }
    
    if(type=='bargain'){
      url = '/subpages/bargainOrderDetail/bargainOrderDetail?id=' + orderId
    }
    if (type == 'group') {
      url = '/subpages1/groupResult/groupResult?tid=' + orderId
    }
    wx.redirectTo({
      url: url
    })
  },
  myjfshop: function () {//积分商城
    wx.navigateTo({
      url: '/subpages/integralShop/integralShop'
    })
  },
  toLottery: function () {
    wx.navigateTo({
      url: '/subpages/getReward/getReward',
    })
  },
  toquestionIndex: function () {
    wx.navigateTo({
      url: '/subpages/questionIndex/questionIndex',
    })
  },
  toFxorder:function(){
    wx.navigateTo({
      url: '/subpages0/fxOrder/fxOrder',
    })
  },
  toAllgoods: function (e) {
    var id = e.currentTarget.dataset.id;
    var type = e.currentTarget.dataset.type;
    var limit = e.currentTarget.dataset.limit;
    var value = e.currentTarget.dataset.value;
    wx.navigateTo({
      url: '/subpages1/searchList/searchList?id=' + id + '&type=' + type + '&limit=' + limit + '&value=' + value
    })
  },
})